import React from 'react'
import memHandleRoute from "./index"
import { fromJS } from 'immutable'

const MemoReducer = (prevState = {...memHandleRoute.state}, action) => {
    let currentState = (fromJS(prevState)).toJS();

    //循环获取要操作的type
    for(let key in memHandleRoute.actionNames) {
        if(memHandleRoute.actionNames[key] === action.type) {
            memHandleRoute.actions[memHandleRoute.actionNames[key]](currentState, action)
            break;
        }
    }

    return currentState;
}

export default MemoReducer;